package org.oschina.plugin;

import javax.servlet.ServletContext;
import org.oschina.api.comment.model.Comment;
import org.oschina.api.dongtan.model.Dongtan;
import org.oschina.api.dongtan.model.DongtanComment;
import org.oschina.api.user.user.model.User;
import org.oschina.plugin.annotation.PluginAspect;
import org.oschina.security.AuthenticationInfo;

/**
 * 插件抽象类
 */
public abstract class AbstractPlugin implements IPlugin {

	@Override
	public abstract String getExplain();

	@Override
	public String getName()
	{
		return this.getClass().getSimpleName();
	}
	
	@Override
	public int getOrder()
	{
		return -1;
	}
	
	/**
	 * 初始化
	 */
	@PluginAspect(type=PluginType.INIT)
	public void init(ServletContext servletContext){};
	
	/**
	 * 容器关闭
	 */
	@PluginAspect(type=PluginType.CLOSE)
	public void close(){};
	
	/**
	 * 登录_之前
	 * @param authenticationInfo
	 */
	@PluginAspect(type=PluginType.LOGIN_BEFORE)
	public void login_before(AuthenticationInfo authenticationInfo){};
	
	/**
	 * 登录_之后
	 * @param authenticationInfo
	 */
	@PluginAspect(type=PluginType.LOGIN_AFTER)
	public void login_after(AuthenticationInfo authenticationInfo){};
	
	/**
	 * 登出
	 * @param user
	 */
	@PluginAspect(type=PluginType.LOGOUT)
	public void logout(User user){};
	
	/**
	 * 发表动弹_之前
	 * @param dongtan
	 */
	@PluginAspect(type=PluginType.DONGTAN_CREATE_BEFORE)
	public void createDongtan_before(Dongtan dongtan){};
	
	/**
	 * 发表动弹_之后
	 * @param dongtan
	 */
	@PluginAspect(type=PluginType.DONGTAN_CREATE_AFTER)
	public void createDongtan_after(Dongtan dongtan){};
	
	/**
	 * 发表动弹评论_之前
	 * @param dongtanComment
	 */
	@PluginAspect(type=PluginType.DONGTAN_COMMENT_CREATE_BEFORE)
	public void createDongtanComment_before(DongtanComment dongtanComment){};
	
	/**
	 * 发表动弹评论_之后
	 * @param dongtanComment
	 */
	@PluginAspect(type=PluginType.DONGTAN_COMMENT_CREATE_AFTER)
	public void createDongtanComment_after(DongtanComment dongtanComment){};
	
	/**
	 * 发表评论_之前
	 * @param comment
	 */
	@PluginAspect(type=PluginType.COMMENT_CREATE_BEFORE)
	public void createComment_before(Comment comment){};
	
	/**
	 * 发表评论_之后
	 * @param comment
	 */
	@PluginAspect(type=PluginType.COMMENT_CREATE_AFTER)
	public void createComment_after(Comment comment){};
}